﻿#include "CTaskExecInfo.h"
#include "CHeader.h"
#include <QDebug>
CTaskExecInfo::CTaskExecInfo()
{
	m_sTaskGuid		  = "";
	m_sGuid      = "";
	m_sTaskExecGuid   = "";
	m_sTaskName       = "";
	m_sTemplateGuid   = "";
	m_nItemCount      = 0;
	m_nExecItemCount  = 0;
	m_nAlarmItemCount = 0;
	m_nExecState      = 2;
	m_sStartTime      = "";
	m_sEndTime        = "";
	m_dEndPower       = 0;
	m_dStartPower     = 0;
	m_dSpeedZ         = 0;
	m_dPollSpeed      = 0;
	m_nCollectAlarmCount = 0;
	m_nCollectExecCount  = 0;
	m_sTaskBreakReason = "";//任务执行失败原因
	m_sTaskExecDes = "";	//任务执行记录描述
	m_sPdfPath = "";
	m_sPdfPathUrl = "";
	m_sSynthPdfPath = "";
	m_sSynthPdfPathUrl = "";
	m_nTaskType = 0;
	m_bIsShow = false;//是否已经在界面中显示
	m_nBelong = 0;
}

CTaskExecInfo::~CTaskExecInfo()
{
	for (int i = 0; i < m_vecPolItemCom.size(); i++)
	{
		if (m_vecPolItemCom[i])
		{
			delete m_vecPolItemCom[i];
			m_vecPolItemCom[i] = nullptr;
		}
	}
	m_vecPolItemCom.clear();

	m_mapPolItemCom.clear();
}

void CTaskExecInfo::copyData(CTaskExecInfo* pTaskExecInfo)
{
	pTaskExecInfo->m_sTaskExecGuid   = m_sTaskExecGuid;               //任务执行记录GUID
	pTaskExecInfo->m_sTaskName       = m_sTaskName;                   //任务名称
	pTaskExecInfo->m_sTemplateGuid   = m_sTemplateGuid;               //模版GUID
	pTaskExecInfo->m_sGuid      = m_sGuid;                  //归属场景Guid
	pTaskExecInfo->m_nExecState      = m_nExecState;                  //任务执行状态 0 未执行  1 已执行  2执行中  3任务中止
	pTaskExecInfo->m_nItemCount      = m_nItemCount;                  //巡检项数量
	pTaskExecInfo->m_nExecItemCount  = m_nExecItemCount;              //已执行的巡检项数量
	pTaskExecInfo->m_nAlarmItemCount = m_nAlarmItemCount;             //报警的巡检项数量
	pTaskExecInfo->m_sStartTime      = m_sStartTime;                  //开始时间
	pTaskExecInfo->m_sEndTime        = m_sEndTime;                    //结束时间
	pTaskExecInfo->m_dStartPower     = m_dStartPower;                 //开始电量
	pTaskExecInfo->m_dEndPower       = m_dEndPower;                   //结束电量
	pTaskExecInfo->m_bIsShow	     = m_bIsShow;					  //是否在界面是已经显示
	pTaskExecInfo->m_nCollectAlarmCount = m_nCollectAlarmCount;		  //持续巡检项报警总数
	pTaskExecInfo->m_nCollectExecCount = m_nCollectExecCount;		  //持续巡检项执行总数
	pTaskExecInfo->m_nBelong = m_nBelong;							  //归属皮带
	pTaskExecInfo->m_nTaskType = m_nTaskType;
}

//深拷贝数据(使用深拷贝数据用完了记得释放里面New的指针)
void CTaskExecInfo::deepCopyData(CTaskExecInfo* pTaskExecInfo)
{
	pTaskExecInfo->m_sTaskExecGuid = m_sTaskExecGuid;                 //任务执行记录GUID
	pTaskExecInfo->m_sTaskGuid = m_sTaskGuid;                         //归属任务Guid
	pTaskExecInfo->m_sTaskName = m_sTaskName;                         //任务名称
	pTaskExecInfo->m_sTemplateGuid = m_sTemplateGuid;                 //模版GUID
	pTaskExecInfo->m_sGuid = m_sGuid;                       //归属场景Guid
	pTaskExecInfo->m_nExecState = m_nExecState;                       //任务执行状态 0 未执行  1 已执行  2执行中  3任务中止
	pTaskExecInfo->m_nItemCount = m_nItemCount;                       //巡检项数量
	pTaskExecInfo->m_nExecItemCount = m_nExecItemCount;               //已执行的巡检项数量
	pTaskExecInfo->m_nAlarmItemCount = m_nAlarmItemCount;             //报警的巡检项数量
	pTaskExecInfo->m_sStartTime = m_sStartTime;                       //开始时间
	pTaskExecInfo->m_sEndTime = m_sEndTime;                           //结束时间
	pTaskExecInfo->m_dStartPower = m_dStartPower;                     //开始电量
	pTaskExecInfo->m_dEndPower = m_dEndPower;                         //结束电量
	pTaskExecInfo->m_bIsShow = m_bIsShow;					          //是否在界面是已经显示
	pTaskExecInfo->m_nCollectAlarmCount = m_nCollectAlarmCount;		  //持续巡检项报警总数
	pTaskExecInfo->m_nCollectExecCount = m_nCollectExecCount;		  //持续巡检项执行总数
	pTaskExecInfo->m_dPollSpeed = m_dPollSpeed;						  //巡检速度
	pTaskExecInfo->m_dSpeedZ = m_dSpeedZ;						  //机器人Z轴速度
	pTaskExecInfo->m_sTaskBreakReason = m_sTaskBreakReason;						  //任务执行失败运营描述
	pTaskExecInfo->m_nBelong = m_nBelong;						  //任务归属皮带
	pTaskExecInfo->m_nTaskType = m_nTaskType;						  //任务类型
	//新增一些用于pdf报表输出需要用到的数据
	pTaskExecInfo->m_sTaskExecDes = m_sTaskExecDes;
	pTaskExecInfo->m_sPdfPath = m_sPdfPath;
	pTaskExecInfo->m_sPdfPathUrl = m_sPdfPathUrl;
	pTaskExecInfo->m_sSynthPdfPath = m_sSynthPdfPath;
	pTaskExecInfo->m_sSynthPdfPathUrl = m_sSynthPdfPathUrl;
	//pTaskExecInfo->m_vecPolItemCom = m_vecPolItemCom;//里面数据也要new和赋值
	for (int i = 0; i < m_vecPolItemCom.size(); i++)
	{
		SCPolItemCom *pPolItemComNew = new SCPolItemCom();
		pPolItemComNew->m_bIsAction = m_vecPolItemCom[i]->m_bIsAction;//是否已执行
		pPolItemComNew->m_bIsSave = m_vecPolItemCom[i]->m_bIsSave;//是否已经保存到数据库
		pPolItemComNew->m_bIsShow = m_vecPolItemCom[i]->m_bIsShow;//是否已经在界面上显示

		//new巡检点
		CPolPoint *pPolPointNew = new CPolPoint();
		m_vecPolItemCom[i]->m_pPolPoint->copyData(pPolPointNew);
		pPolItemComNew->m_pPolPoint = pPolPointNew;//赋值

		if (0 == m_vecPolItemCom[i]->m_pPolItem->m_nDevType)//设备类型  0 本体(传感器)  1云台
		{
			CPolItemSensor *pItemSensorNew = new CPolItemSensor();//new巡检项
			CPolItemSensor* pPolItemSensorDataNow = (CPolItemSensor*)m_vecPolItemCom[i]->m_pPolItem;
			pPolItemSensorDataNow->copyData(pItemSensorNew);
			pPolItemComNew->m_pPolItem = pItemSensorNew;//赋值

			CItemResultSensor *pItemResultSensorNew = new CItemResultSensor();//new本体巡检结果
			CItemResultSensor *pSensorResultNow = (CItemResultSensor *)m_vecPolItemCom[i]->m_ItemResult;
			pSensorResultNow->copyData(pItemResultSensorNew);
			pPolItemComNew->m_ItemResult = pItemResultSensorNew;//赋值

		}
		else
		{
			CPolItemCamer *pItemCamerNew = new CPolItemCamer();//new巡检项
			CPolItemCamer* pPolItemCamerDataNow = (CPolItemCamer*)m_vecPolItemCom[i]->m_pPolItem;
			pPolItemCamerDataNow->copyData(pItemCamerNew);
			pPolItemComNew->m_pPolItem = pItemCamerNew;//赋值

			CItemResultCamera *pItemResultCamerNew = new CItemResultCamera();//new云台巡检结果
			CItemResultCamera *pCamerResultNow = (CItemResultCamera *)m_vecPolItemCom[i]->m_ItemResult;
			pCamerResultNow->copyData(pItemResultCamerNew);
			pPolItemComNew->m_ItemResult = pItemResultCamerNew;//赋值
		}

		//连续检测
		for (int j = 0; j < m_vecPolItemCom[i]->m_vecItemResult.size(); j++)//持续任务巡检项结果
		{
			if (0 == m_vecPolItemCom[i]->m_vecItemResult[j]->m_nDevType)//设备类型  0 本体(传感器)  1云台
			{
				//本体连续检测暂无
			}
			else
			{
				CItemResultCamera *pItemResultCamerNew = new CItemResultCamera();//new云台巡检结果
				CItemResultCamera *pCamerResultNow = (CItemResultCamera *)m_vecPolItemCom[i]->m_vecItemResult[j];
				pCamerResultNow->copyData(pItemResultCamerNew);
				pPolItemComNew->m_vecItemResult.push_back(pItemResultCamerNew);
			}
		}
		

		pTaskExecInfo->m_vecPolItemCom.push_back(pPolItemComNew);
	}
}

//释放深拷贝数据
//void CTaskExecInfo::deleteDeepCopyData()
//{
//	for (int i = 0; i < m_vecPolItemCom.size(); i++)
//	{
//		//先释放连续检测数据
//		for (CItemResultBase* pData : m_vecPolItemCom[i]->m_vecItemResult) {
//			delete pData;
//			pData = nullptr;
//		}
//		m_vecPolItemCom[i]->m_vecItemResult.clear();
//
//		//释放巡检点
//		m_vecPolItemCom[i]->m_pPolPoint->deleteDeepCopyData();//释放深拷贝的数据出来
//		delete m_vecPolItemCom[i]->m_pPolPoint;
//		m_vecPolItemCom[i]->m_pPolPoint = nullptr;
//
//		//释放巡检项
//		delete m_vecPolItemCom[i]->m_pPolItem;
//		m_vecPolItemCom[i]->m_pPolItem = nullptr;
//
//		//释放巡检项结果
//		delete m_vecPolItemCom[i]->m_ItemResult;
//		m_vecPolItemCom[i]->m_ItemResult = nullptr;
//	}
//}

/********************************************************************************
*Description: 创建执行任务基础数据
*FunParameter: pPolArea区域对象  cTaskInfo 任务对象 CTemplateInfo 模板对象
*FunReturnValue:
*Author:Gaojia
*Date:2024/03/19
*ChangeDate:
*Modifier:
*ModifyReason:
*Version:V1.0.0
********************************************************************************/
void CTaskExecInfo::deleteDeepCopyData()
{
	resetData();
}
void CTaskExecInfo::createTaskInfo(CPolArea *pPolArea, CTaskInfo cTaskInfo, CTemplateInfo cTemplateInfo, int nStartPower ,int nSmallSceneType)
{
	//1.复位数据
	resetData();
	//2.创建m_vecPolItemCom
	m_sTaskExecGuid = createGuid();
	m_sTaskGuid = cTaskInfo.m_sTaskGuid;
	m_sTaskName = cTaskInfo.m_sTaskName;
	m_sTemplateGuid = cTemplateInfo.m_sTemplateGuid;
	m_sGuid = cTaskInfo.m_sGuid;
	m_dPollSpeed = cTemplateInfo.m_dPollSpeed;
	m_dSpeedZ = cTemplateInfo.m_dSpeedZ;
	m_nExecItemCount = 0;
	m_nAlarmItemCount = 0;
	m_sStartTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
	m_dStartPower = nStartPower;//开始电量
	m_nTaskType = cTaskInfo.m_nTaskType;
	for (int i = 0; i < 20; i++)
	{
		m_vecTaskIndex.push_back(-1);
	}
	int nPointIndex = 0;
	int nConPointIndex = 0;
	for (int i = 0; i < cTemplateInfo.m_vecItemID.size(); i++)
	{
		QMap<QString, CPolPoint*> mapPolPoint = pPolArea->m_mapPolPoint;
		for (QMap<QString, CPolPoint *>::iterator j = mapPolPoint.begin(); j != mapPolPoint.end(); j++)
		{
			if (!j.value()->m_mapPolItem.contains(cTemplateInfo.m_vecItemID[i]))
			{
				continue;
			}
			SCPolItemCom *pSCPolItemCom = createPolItemCom(j.value()->m_mapPolItem[cTemplateInfo.m_vecItemID[i]], j.value());		
			if (nPointIndex <= 0)
			{
				QMap<int, SCPolItemCom*>mapPolItemCom;
				mapPolItemCom.insert(pSCPolItemCom->m_pPolItem->m_nIndex, pSCPolItemCom);
				m_mapPolItemCom.insert(nPointIndex, mapPolItemCom);
				nPointIndex++;
				continue;
			}
			SCPolItemCom *pPolItemCom = m_mapPolItemCom.value(nPointIndex - 1).begin().value();
			if (pPolItemCom->m_pPolPoint->m_dPointLocation != j.value()->m_dPointLocation)
			{
				QMap<int, SCPolItemCom*>mapPolItemCom;
				mapPolItemCom.insert(pSCPolItemCom->m_pPolItem->m_nIndex, pSCPolItemCom);
				m_mapPolItemCom.insert(nPointIndex, mapPolItemCom);
				nPointIndex++;
				continue;
			}

			bool bAdd = false;
			if (cTemplateInfo.m_vecItemOrder.size() > i&&i > 0)
			{
				if (cTemplateInfo.m_vecItemOrder[i] != cTemplateInfo.m_vecItemOrder[i - 1])
				{
					bAdd = true;
				}
			}
			if (bAdd)
			{
				QMap<int, SCPolItemCom*>mapPolItemCom;
				mapPolItemCom.insert(pSCPolItemCom->m_pPolItem->m_nIndex, pSCPolItemCom);
				m_mapPolItemCom.insert(nPointIndex, mapPolItemCom);
				nPointIndex++;
			}
			else
			{
				m_mapPolItemCom[nPointIndex - 1].insert(pSCPolItemCom->m_pPolItem->m_nIndex, pSCPolItemCom);
			}			
		}
	}
	//3.创建m_mapCorrIndex和m_vecTaskArray
	m_vecTaskArray.clear();
	m_vecTaskArray.push_back(m_dPollSpeed * 1000);
	m_vecTaskArray.push_back(1);
	m_vecTaskArray.push_back(m_vecPolItemCom.size());
	int j = 0;
	for (QMap<int, QMap<int, SCPolItemCom*>>::iterator itor = m_mapPolItemCom.begin(); itor != m_mapPolItemCom.end(); itor++)
	{
		bool bHaveItem = false;
		int nLocation = itor.value().first()->m_pPolPoint->m_dPointLocation;
		for (QMap<int, SCPolItemCom*>::iterator i = itor.value().begin(); i != itor.value().end(); i++)
		{
			qDebug() << i.value()->m_pPolItem->m_sItemName;
			//加入持续巡检项起点和终点序号
			if (i.value()->m_pPolItem->m_nDevTypeCode == 8)
			{
				CPolItemCamer *pPolItemCamer = (CPolItemCamer*)i.value()->m_pPolItem;
				if (pPolItemCamer->m_nCheckType == 1 && (pPolItemCamer->m_nCollectIndex == 0 || pPolItemCamer->m_nCollectIndex == 1))
				{
					if (nConPointIndex < 20)
					{
						m_vecTaskIndex[nConPointIndex] = j;
						nConPointIndex++;
					}

				}
			}

			m_vecPolItemCom.push_back(i.value());
			int nItemDevTypeCode = i.value()->m_pPolItem->m_nDevTypeCode;
			//if(nItemDevTypeCode == enCamer || nItemDevTypeCode == enIR )
			if (nItemDevTypeCode == enCamer || nItemDevTypeCode == enIR|| nItemDevTypeCode==enVoice)
			{
				m_mapCorrIndex.insert(j, m_vecPolItemCom.size() - 1);
				m_vecTaskArray.push_back(j);
				CPolItemCamer *pPolItemCamer = (CPolItemCamer *)i.value()->m_pPolItem;
				int nLocationZ = pPolItemCamer->m_dItemZ * 10;//巡检项坐标Z(现在是cm)
				int nIndex = pPolItemCamer->m_dAngelCamer;
				int nTime = pPolItemCamer->m_dCollectTime;
				m_vecTaskArray.push_back(nLocation / 65536);
				m_vecTaskArray.push_back(nLocation % 65536);
				m_vecTaskArray.push_back(nLocationZ);
				m_vecTaskArray.push_back(nIndex);//预置点序号
				//if (nSmallSceneType == 0 || nSmallSceneType == 3)//南电和滨海发送云台转动时间
				//{
				//	m_vecTaskArray.push_back(pPolItemCamer->m_dCollectTime * 1000);//云台转动时间 
				//}
				//else
				//{
				//	m_vecTaskArray.push_back(5000);//采集时间
				//}
				m_vecTaskArray.push_back(pPolItemCamer->m_dCollectTime * 1000);//云台转动时间 
				j++;
				bHaveItem = true;
			}
		}
		if (!bHaveItem)
		{
			m_mapCorrIndex.insert(j, m_vecPolItemCom.size() - 1);
			m_vecTaskArray.push_back(j);
			m_vecTaskArray.push_back(nLocation / 65536);
			m_vecTaskArray.push_back(nLocation % 65536);
			m_vecTaskArray.push_back(0);
			m_vecTaskArray.push_back(0);//预置点序号
			m_vecTaskArray.push_back(5000);//默认5000
			j++;
		}
	}
	m_vecTaskArray[2] = j;  //PLC实际执行的巡检项总数
	m_nItemCount = m_vecPolItemCom.size();
}
//void CTaskExecInfo::createTaskInfo(CPolArea *pPolArea, CTaskInfo cTaskInfo, CTemplateInfo cTemplateInfo, int nStartPower)
//{
//	//1.复位数据
//	resetData();
//	//2.创建m_vecPolItemCom
//	m_sTaskExecGuid = createGuid();
//	m_sTaskGuid = cTaskInfo.m_sTaskGuid;
//	m_sTaskName = cTaskInfo.m_sTaskName;
//	m_sTemplateGuid = cTemplateInfo.m_sTemplateGuid;
//	m_sGuid = cTaskInfo.m_sGuid;
//	m_dPollSpeed = cTemplateInfo.m_dPollSpeed;
//	m_dSpeedZ = cTemplateInfo.m_dSpeedZ;
//	m_nExecItemCount = 0;
//	m_nAlarmItemCount = 0;
//	m_sStartTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
//	m_dStartPower = nStartPower;//开始电量
//	for (int i = 0; i < cTemplateInfo.m_vecItemID.size(); i++)
//	{
//		QMap<QString, CPolPoint*> mapPolPoint = pPolArea->m_mapPolPoint;
//		for (QMap<QString, CPolPoint *>::iterator j = mapPolPoint.begin(); j != mapPolPoint.end(); j++)
//		{
//			if (j.value()->m_mapPolItem.contains(cTemplateInfo.m_vecItemID[i]))
//			{
//				SCPolItemCom *pSCPolItemCom = createPolItemCom(j.value()->m_mapPolItem[cTemplateInfo.m_vecItemID[i]], j.value());
//				if (m_mapPolItemCom.contains(j.value()->m_dPointLocation))
//				{
//					m_mapPolItemCom[j.value()->m_dPointLocation].insert(pSCPolItemCom->m_pPolItem->m_nIndex, pSCPolItemCom);
//				}
//				else
//				{
//					QMap<int, SCPolItemCom*>mapPolItemCom;
//					mapPolItemCom.insert(pSCPolItemCom->m_pPolItem->m_nIndex, pSCPolItemCom);
//					m_mapPolItemCom.insert(j.value()->m_dPointLocation, mapPolItemCom);
//				}
//			}
//		}
//	}	
//	//3.创建m_mapCorrIndex和m_vecTaskArray
//	m_vecTaskArray.clear();
//	m_vecTaskArray.push_back(m_dPollSpeed * 1000);
//	m_vecTaskArray.push_back(1); 
//	m_vecTaskArray.push_back(m_vecPolItemCom.size());
//	int j = 0;
//	for (QMap<int, QMap<int, SCPolItemCom*>>::iterator itor = m_mapPolItemCom.begin(); itor != m_mapPolItemCom.end(); itor++)
//	{
//		bool bHaveItem = false;
//		int nLocation = itor.value().first()->m_pPolPoint->m_dPointLocation;
//		for (QMap<int, SCPolItemCom*>::iterator i = itor.value().begin(); i != itor.value().end(); i++)
//		{
//			m_vecPolItemCom.push_back(i.value());
//			int nItemDevTypeCode = i.value()->m_pPolItem->m_nDevTypeCode;
//			if (nItemDevTypeCode == enCamer || nItemDevTypeCode == enIR || nItemDevTypeCode == enVoice)
//			{
//				m_mapCorrIndex.insert(j, m_vecPolItemCom.size() - 1);
//				m_vecTaskArray.push_back(j);
//				CPolItemCamer *pPolItemCamer = (CPolItemCamer *)i.value()->m_pPolItem;
//				int nLocationZ = pPolItemCamer->m_dItemZ * 10;//巡检项坐标Z(现在是cm)
//				int nIndex = pPolItemCamer->m_dAngelCamer;
//				int nTime = pPolItemCamer->m_dCollectTime;
//				m_vecTaskArray.push_back(nLocation / 65536);
//				m_vecTaskArray.push_back(nLocation % 65536);
//				m_vecTaskArray.push_back(nLocationZ);
//				m_vecTaskArray.push_back(nIndex);//预置点序号
//				m_vecTaskArray.push_back(10000);//默认5000
//				j++;
//				bHaveItem = true;
//			}	
//		}
//		if (!bHaveItem)
//		{
//			m_mapCorrIndex.insert(j, m_vecPolItemCom.size() - 1);
//			m_vecTaskArray.push_back(j);
//			m_vecTaskArray.push_back(nLocation / 65536);
//			m_vecTaskArray.push_back(nLocation % 65536);
//			m_vecTaskArray.push_back(0);
//			m_vecTaskArray.push_back(0);//预置点序号
//			m_vecTaskArray.push_back(5000);//默认5000
//			j++;
//		}
//	}
//	m_vecTaskArray[2] = j;  //PLC实际执行的巡检项总数
//	m_nItemCount = m_vecPolItemCom.size();
//}

SCPolItemCom * CTaskExecInfo::createPolItemCom(CPolItem *pPolItem, CPolPoint *pPolPoint)
{
	SCPolItemCom *pPolItemCom = new SCPolItemCom();
	pPolItemCom->m_pPolPoint = new CPolPoint();
	pPolPoint->copyData(pPolItemCom->m_pPolPoint);
	switch (pPolItem->m_nDevType)
	{
		case enOntology:
		{
			pPolItemCom->m_ItemResult = new CItemResultSensor();
			pPolItemCom->m_pPolItem = new CPolItemSensor();
			pPolItemCom->m_ItemResult->m_sItemResultGuid = createGuid();
			pPolItemCom->m_ItemResult->m_sPolAreaGuid = pPolPoint->m_sPolAreaGuid;
			pPolItemCom->m_ItemResult->m_sPointGuid = pPolPoint->m_sPointGuid;
			pPolItemCom->m_ItemResult->m_sItemGuid = pPolItem->m_sItemGuid;
			pPolItemCom->m_ItemResult->m_sTemplateGuid = m_sTemplateGuid;
			pPolItemCom->m_ItemResult->m_sTaskGuid = m_sTaskGuid;
			pPolItemCom->m_ItemResult->m_sTaskName = m_sTaskName;
			pPolItemCom->m_ItemResult->m_sItemName = pPolItem->m_sItemName;//巡检项名称
			pPolItemCom->m_ItemResult->m_nDevType = enOntology;
			pPolItemCom->m_ItemResult->m_nDevTypeCode = pPolItem->m_nDevTypeCode;//巡检项设备类型编码  
			pPolItemCom->m_ItemResult->m_nCheckType = pPolItem->m_nCheckType;//数据上报类型 0.调用返回  1.持续任务主动上报
			pPolItemCom->m_ItemResult->m_sGuid = pPolItem->m_sGuid;//归属场景Guid
			pPolItemCom->m_ItemResult->m_sDataThreadHoldHH = pPolItem->m_sDataThreadHoldHH;//数字阈值--高高报警
			pPolItemCom->m_ItemResult->m_sDataThreadHoldLL = pPolItem->m_sDataThreadHoldLL;//数字阈值--低低报警
			pPolItemCom->m_ItemResult->m_sDataThreadHoldH = pPolItem->m_sDataThreadHoldH;//数字阈值--高报警
			pPolItemCom->m_ItemResult->m_sDataThreadHoldL = pPolItem->m_sDataThreadHoldL;//数字阈值--低报警
			pPolItemCom->m_ItemResult->m_sTaskExecGuid = m_sTaskExecGuid;//任务执行记录GUID
			pPolItemCom->m_ItemResult->m_nBelong = pPolItem->m_nBelong;//皮带归属
		}
		break;
		case enSubDev1:
		{
			pPolItemCom->m_ItemResult = new CItemResultCamera();
			pPolItemCom->m_pPolItem = new CPolItemCamer();
			pPolItemCom->m_ItemResult->m_sItemResultGuid = createGuid();
			pPolItemCom->m_ItemResult->m_sItemResultGuid = createGuid();
			pPolItemCom->m_ItemResult->m_sPolAreaGuid = pPolPoint->m_sPolAreaGuid;
			pPolItemCom->m_ItemResult->m_sPointGuid = pPolPoint->m_sPointGuid;
			pPolItemCom->m_ItemResult->m_sItemGuid = pPolItem->m_sItemGuid;
			pPolItemCom->m_ItemResult->m_sTemplateGuid = m_sTemplateGuid;
			pPolItemCom->m_ItemResult->m_sTaskGuid = m_sTaskGuid;
			pPolItemCom->m_ItemResult->m_sTaskName = m_sTaskName;
			pPolItemCom->m_ItemResult->m_sItemName = pPolItem->m_sItemName;//巡检项名称
			pPolItemCom->m_ItemResult->m_nDevType = enSubDev1;
			pPolItemCom->m_ItemResult->m_nDevTypeCode = pPolItem->m_nDevTypeCode;//巡检项设备类型编码  
			pPolItemCom->m_ItemResult->m_nCheckType = pPolItem->m_nCheckType;//数据上报类型 0.调用返回  1.持续任务主动上报
			pPolItemCom->m_ItemResult->m_sGuid = pPolItem->m_sGuid;//归属场景Guid
			pPolItemCom->m_ItemResult->m_sDataThreadHoldHH = pPolItem->m_sDataThreadHoldHH;//数字阈值--高高报警
			pPolItemCom->m_ItemResult->m_sDataThreadHoldLL = pPolItem->m_sDataThreadHoldLL;//数字阈值--低低报警
			pPolItemCom->m_ItemResult->m_sDataThreadHoldH = pPolItem->m_sDataThreadHoldH;//数字阈值--高报警
			pPolItemCom->m_ItemResult->m_sDataThreadHoldL = pPolItem->m_sDataThreadHoldL;//数字阈值--低报警
			pPolItemCom->m_ItemResult->m_sTaskExecGuid = m_sTaskExecGuid;//任务执行记录GUID
			pPolItemCom->m_ItemResult->m_nBelong = pPolItem->m_nBelong;//皮带归属
			
		}
		break;
	default:
		pPolItemCom->m_ItemResult = new CItemResultSensor();
		pPolItemCom->m_pPolItem = new CPolItemSensor();
		pPolItemCom->m_ItemResult->m_sItemResultGuid = createGuid();
		pPolItemCom->m_ItemResult->m_sPolAreaGuid = pPolPoint->m_sPolAreaGuid;
		pPolItemCom->m_ItemResult->m_sPointGuid = pPolPoint->m_sPointGuid;
		pPolItemCom->m_ItemResult->m_sItemGuid = pPolItem->m_sItemGuid;
		pPolItemCom->m_ItemResult->m_sTemplateGuid = m_sTemplateGuid;
		pPolItemCom->m_ItemResult->m_sTaskGuid = m_sTaskGuid;
		pPolItemCom->m_ItemResult->m_sTaskName = m_sTaskName;
		pPolItemCom->m_ItemResult->m_sItemName = pPolItem->m_sItemName;//巡检项名称
		pPolItemCom->m_ItemResult->m_nDevType = enOntology;
		pPolItemCom->m_ItemResult->m_nDevTypeCode = pPolItem->m_nDevTypeCode;//巡检项设备类型编码  
		pPolItemCom->m_ItemResult->m_nCheckType = pPolItem->m_nCheckType;//数据上报类型 0.调用返回  1.持续任务主动上报
		pPolItemCom->m_ItemResult->m_sGuid = pPolItem->m_sGuid;//归属场景Guid
		pPolItemCom->m_ItemResult->m_sDataThreadHoldHH = pPolItem->m_sDataThreadHoldHH;//数字阈值--高高报警
		pPolItemCom->m_ItemResult->m_sDataThreadHoldLL = pPolItem->m_sDataThreadHoldLL;//数字阈值--低低报警
		pPolItemCom->m_ItemResult->m_sDataThreadHoldH = pPolItem->m_sDataThreadHoldH;//数字阈值--高报警
		pPolItemCom->m_ItemResult->m_sDataThreadHoldL = pPolItem->m_sDataThreadHoldL;//数字阈值--低报警
		pPolItemCom->m_ItemResult->m_sTaskExecGuid = m_sTaskExecGuid;//任务执行记录GUID
		pPolItemCom->m_ItemResult->m_nBelong = pPolItem->m_nBelong;//皮带归属
		break;
	}
	pPolItem->copyData(pPolItemCom->m_pPolItem);
	return pPolItemCom;
}

void CTaskExecInfo::createTaskArray()
{
}

void CTaskExecInfo::resetData()
{
	m_sGuid      = "";
	m_sTaskExecGuid   = "";
	m_sTaskName       = "";
	m_sTemplateGuid   = "";
	m_sTaskGuid       = "";
	m_nItemCount      = 0;
	m_nExecItemCount  = 0;
	m_nAlarmItemCount = 0;
	m_nCollectAlarmCount = 0;
	m_nCollectExecCount = 0;
	m_nExecState      = 2;
	m_sStartTime      = "";
	m_sEndTime        = "";
	m_dEndPower       = 0;
	m_dStartPower     = 0;
	m_nBelong		  = 0;
	m_sPdfPath        = "";
	m_sPdfPathUrl = "";
	m_sSynthPdfPath = "";
	m_sSynthPdfPathUrl = "";
	m_bIsShow = false;
	m_sTaskBreakReason = "";
	m_sTaskExecDes = "";
	m_vecTaskArray.clear();
	m_vecTaskIndex.clear();
	m_mapCorrIndex.clear();
	for (int i = 0; i < m_vecPolItemCom.size(); i++)
	{
		if (m_vecPolItemCom[i]->m_ItemResult != nullptr)
		{
			delete m_vecPolItemCom[i]->m_ItemResult;
			m_vecPolItemCom[i]->m_ItemResult = nullptr;
		}
		if (m_vecPolItemCom[i]->m_pPolItem != nullptr)
		{
			delete m_vecPolItemCom[i]->m_pPolItem;
			m_vecPolItemCom[i]->m_pPolItem = nullptr;
		}
		if (m_vecPolItemCom[i]->m_pPolPoint != nullptr)
		{
			delete m_vecPolItemCom[i]->m_pPolPoint;
			m_vecPolItemCom[i]->m_pPolPoint = nullptr;
		}
		delete m_vecPolItemCom[i];
		m_vecPolItemCom[i] = nullptr;
	}
	m_vecPolItemCom.resize(0);
	m_mapPolItemCom.clear();
}
